package com.xuecheng.auth.domain.strategy;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-09-07  15:22
 */
@Getter
@AllArgsConstructor
public enum AuthTypeEnum {


    PASSWORD("password", "密码模式", PasswordAuthStrategy.class),
    WX("wx", "微信扫码", WxAuthStrategy.class),
    SMS("sms", "短信验证码模式", SmsAuthStrategy.class);

    private String type;
    private String desc;
    private Class<? extends AuthStrategy>  authStrategy;
    private static Map<String, AuthTypeEnum> cache;

    static {
        cache =  Arrays.stream(AuthTypeEnum.values()).collect(Collectors.toMap(AuthTypeEnum::getType, Function.identity()));
    }

    public static AuthTypeEnum of(String type){
        return cache.get(type);
    }


}
